
// Replication Data for "Ethnicity and Power in Sub-Saharan Africa: Do Colonial Institutions Still Matter?" //

clear              
set matsize 800
version 16.1
set more off

*********************************Data Source************************************

/*The Ethnic Power Relations (EPR) dataset, https://icr.ethz.ch/data/epr/core/
   Excel format: https://icr.ethz.ch/data/epr/core/EPR-2021.xls*/

*********************************Data Preparation*******************************

/* file: MurdockCodes+ID.dta */

replace groupid=40401000 if name=="BALANTE" & culturegrp=="Guinea"
replace groupid=40405000 if name=="PEPEL" & culturegrp=="Guinea"
replace groupid=42002000 if name=="FOUTATORO" & culturegrp=="Fulani, Sedentary"
replace groupid=42003000 if name=="WOLOF" & culturegrp=="Senegal"
replace groupid=43401000 if name=="FON" & culturegrp=="Ewe-Fon"
replace groupid=43402000 if name=="Yoruba, Ife" & culturegrp=="Yoruba"
replace groupid=43403000 if name=="DENDI" & culturegrp=="Mole"
replace groupid=43701000 if name=="BAULE" & culturegrp=="Akan"
replace groupid=43702000 if name=="BETE" & culturegrp=="Kru"
replace groupid=43703000 if name=="MALINKE" & culturegrp=="Mande, Nuclear"
replace groupid=43704000 if name=="ATTIE" & culturegrp=="Akan"
replace groupid=43705000 if name=="GURO" & culturegrp=="Mande, Southern"
replace groupid=43801000 if name=="SONINKE" & culturegrp=="Mande, Nuclear"
replace groupid=43802000 if name=="Futajalonke" & culturegrp=="Fulani, Sedentary"
replace groupid=43803000 if name=="SUSU" & culturegrp=="Mande, Nuclear"
replace groupid=45003020 if name=="DAN" & culturegrp=="Mande, Southern"
replace groupid=45003050 if name=="KRAN" & culturegrp=="Kru"
replace groupid=45003060 if name=="KRU" & culturegrp=="Kru"
replace groupid=45104000 if name=="MENDE" & culturegrp=="Mende-Temne"
replace groupid=45105030 if name=="LIMBA" & culturegrp=="Mande, Nuclear"
replace groupid=45105060 if name=="TEMNE" & culturegrp=="Mende-Temne"
replace groupid=45201000 if name=="ASHANTI" & culturegrp=="Akan"
replace groupid=45202000 if name=="EWE" & culturegrp=="Ewe-Fon"
replace groupid=45203000 if name=="ADANGME" & culturegrp=="Ewe-Fon"
replace groupid=45206000 if name=="DAGOMBA" & culturegrp=="Mole"
replace groupid=45207000 if name=="AKYEM" & culturegrp=="Akan"
replace groupid=46101000 if name=="EWE" & culturegrp=="Ewe-Fon"
replace groupid=46102000 if name=="KABRE" & culturegrp=="Borgu-Mango"
replace groupid=47102000 if name=="DUALA" & culturegrp=="Biafra Coast"
replace groupid=47101000 if name=="BAMILEKE" & culturegrp=="Cameroon Highlands"
replace groupid=47501000 if name=="SOKOTO" & culturegrp=="Hausa"
replace groupid=47502000 if name=="EDO" & culturegrp=="Ibo-Edo"
replace groupid=47503000 if name=="IJAW" & culturegrp=="Mende-Temne"
replace groupid=47505000 if name=="TIGON" & culturegrp=="Tiv-Junkun"
replace groupid=47506000 if name=="YORUBA" & culturegrp=="Yoruba"
replace groupid=48103000 if name=="FANG" & culturegrp=="Fang-Dzem"
replace groupid=48105000 if name=="MPONGWE" & culturegrp=="Biafra Coast"
replace groupid=48205020 if name=="BAYA" & culturegrp=="Banda-Baya"
replace groupid=48205070 if name=="BAGIRMI" & culturegrp=="Bagirmi-Sara"
replace groupid=48206080 if name=="YAKOMA" & culturegrp=="Banda-Baya"
replace groupid=48301000 if name=="SAHEL" & culturegrp=="Arabs, Littoral North Africa"
replace groupid=48302200 if name=="BIDEYAT" & culturegrp=="Teda"
replace groupid=48302200 if name=="ZAGHAWA" & culturegrp=="Arabs, Bedoin"
replace groupid=48304000 if name=="BAGIRMI" & culturegrp=="Bagirmi-Sara"
replace groupid=48402000 if name=="TEKE" & culturegrp=="Lower Congo"
replace groupid=48405010 if name=="KONGO" & culturegrp=="Lower Congo"
replace groupid=48410000 if name=="VILI" & culturegrp=="Lower Congo"
replace groupid=49001000 if name=="AZANDE" & culturegrp=="Azande"
replace groupid=49003000 if name=="KONGO" & culturegrp=="Lower Congo"
replace groupid=49005000 if name=="LELE" & culturegrp=="Kasai"
replace groupid=49007000 if name=="LUBA" & culturegrp=="Luba"
replace groupid=49009000 if name=="LULUA" & culturegrp=="Luba"
replace groupid=49011000 if name=="YEKE" & culturegrp=="Luba"
replace groupid=49012000 if name=="TETELA" & culturegrp=="Mongo"
replace groupid=50002000 if name=="GANDA" & culturegrp=="East Lacustrine Bantu"
replace groupid=50004000 if name=="SOGA" & culturegrp=="East Lacustrine Bantu"
replace groupid=50007000 if name=="KARAMOJONG" & culturegrp=="Karamojong"
replace groupid=50009120 if name=="ACHOLI" & culturegrp=="Nilotes, Southern"
replace groupid=50009210 if name=="TESO" & culturegrp=="Karamojong"
replace groupid=50011000 if name=="NYORO" & culturegrp=="East Lacustrine Bantu"
replace groupid=50101000 if name=="MASAI" & culturegrp=="Masai"
replace groupid=50103000 if name=="KIKUYU" & culturegrp=="Kenya Highlands"
replace groupid=50102000 if name=="KAMBA" & culturegrp=="Kenya Highlands"
replace groupid=50104000 if name=="KISI" & culturegrp=="Ngonde"
replace groupid=50106000 if name=="LUO" & culturegrp=="Nilotes, Southern"
replace groupid=51601000 if name=="RUNDI" & culturegrp=="West Lacustrine Bantu"
replace groupid=51602000 if name=="RUNDI" & culturegrp=="West Lacustrine Bantu"
replace groupid=51701000 if name=="RUANDA" & culturegrp=="West Lacustrine Bantu"
replace groupid=51702000 if name=="RUANDA" & culturegrp=="West Lacustrine Bantu"
replace groupid=54001000 if name=="KONGO" & culturegrp=="Lower Congo"
replace groupid=54003000 if name=="CHOKWE" & culturegrp=="Lunda"
replace groupid=54004000 if name=="MBUNDU" & culturegrp=="Western Angola"
replace groupid=54101000 if name=="MAKONDE" & culturegrp=="Yao-Makonde"
replace groupid=54103000 if name=="NDAU" & culturegrp=="Shona-Thonga"
replace groupid=54104000 if name=="CHOPI" & culturegrp=="Shona-Thonga"
replace groupid=55101000 if name=="BEMBA" & culturegrp=="Bemba-Lamba"
replace groupid=55102000 if name=="KAONDE" & culturegrp=="Bemba-Lamba"
replace groupid=55103000 if name=="LOZI" & culturegrp=="Barotseland"
replace groupid=55104000 if name=="LUNDA" & culturegrp=="Lunda"
replace groupid=55105000 if name=="LUVALE" & culturegrp=="Lunda"
replace groupid=55106000 if name=="NYANJA" & culturegrp=="Maravi"
replace groupid=55107000 if name=="ILA" & culturegrp=="Ila-Tonga"
replace groupid=55201100 if name=="NDEBELE" & culturegrp=="Nguni"
replace groupid=55301000 if name=="YAO" & culturegrp=="Yao-Makonde"
replace groupid=55302000 if name=="CHEWA" & culturegrp=="Maravi"
replace groupid=55303000 if name=="TUMBUKA" & culturegrp=="Bemba-Lamba"
replace groupid=58002000 if name=="MERINA" & culturegrp=="Yao-Makonde"
replace groupid=45102000 if name=="KONO" & culturegrp=="Mende-Temne"
replace groupid=49009000 if name=="LULUA" & culturegrp=="Luba"
replace groupid=50105000 if name=="WANGA" & culturegrp=="East Lacustrine Bantu"
replace groupid=45105030 if name=="LIMBA" & culturegrp=="Mande, Nuclear"
replace groupid=49004000 if name=="EKONDA" & culturegrp=="Mongo"
replace groupid=45003040 if name=="KPELLE" & culturegrp=="Mende-Temne"


//Precolonial Societies - from Murdock//

/* file: Murdock-EA-2011+ID.dta */

clear
use "D:\Rutgers-Camden\0. Beth Project\Dataverse\2020 Ethnicity\SSA Colonial Institutions - Ethnicity _ Power Data Set\Precolonial data\Murdock-EA-2011+ID.dta"

gen states=.
replace states=5 if v90=="states"
replace states=4 if v90=="little states"
replace states=3 if v90=="minimal states"
replace states=2 if v90=="autonomous local communities"
replace states=1 if v90=="peace groups transcending local communities"

gen complexity=.
replace complexity=7 if v30=="Complex settlement"
replace complexity=6 if v30=="Compact and relatively permanent settlements"
replace complexity=5 if v30=="Compact but impermenant settlements"
replace complexity=4 if v30=="Separated hamlets, forming a single community" 
replace complexity=3 if v30=="Semisedentary"
replace complexity=2 if v30=="Neighborhoods of dispersed  family homesteads"
replace complexity=1 if v30=="Nomadic or fully migratory"

gen density=.
replace density=6 if v31=="Cities of 50,000 or more"
replace density=5 if v31=="Towns of 5,000-50,000"
replace density=4 if v31=="400-1,000"
replace density=3 if v31=="200-399"
replace density=2 if v31=="100-199"
replace density=1 if v31=="50-99"

gen hierarchy=.
replace hierarchy=4 if v33=="Three levels"
replace hierarchy=3 if v33=="Two levels"
replace hierarchy=2 if v33=="One levels"
replace hierarchy=1 if v33=="No levels"

gen centralization=.
replace centralization=8 if states==5 & density>4
replace centralization=7 if states==4 & density>4 | hierarchy==4 & centralization>5
replace centralization=6 if 2<states<5 & hierarchy==3 & centralization==.
replace centralization=5 if density==4 & centralization==.
replace centralization=4 if states==3 & complexity==4 & hierarchy==2 & centralization==.
replace centralization=3 if states<3 & hierarchy==2 | density>2 & centralization==.
replace centralization=2 if hierarchy==2 & centralization==.
replace centralization=1 if complexity>3 & hierarchy==1 & centralization==.
replace centralization=0 if hierarchy!=. & centralization==.